<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>得到某连接的最后一条错误信息</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.pg-insert.html">« pg_insert</a></li>
      <li style="float: right;"><a href="function.pg-last-notice.html">pg_last_notice »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.pgsql.html">PostgreSQL 函数</a></li>
    <li>得到某连接的最后一条错误信息</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.pg-last-error" class="refentry">
   <div class="refnamediv">
    <h1 class="refname">pg_last_error</h1>
    <p class="verinfo">(PHP 4 &gt;= 4.2.0, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">pg_last_error</span> &mdash; <span class="dc-title">得到某连接的最后一条错误信息</span></p>

   </div>
   <div class="refsect1 unknown-seealsp" id="refsect1-function.pg-last-error-unknown-seealsp">
    <h3 class="title">说明</h3>
     <div class="methodsynopsis dc-description">
      <span class="methodname"><strong>pg_last_error</strong></span>(<span class="methodparam"><span class="type">resource</span> <code class="parameter">$connection</code><span class="initializer"> = ?</span></span>): <span class="type">string</span></div>

    <p class="para rdfs-comment">
     <span class="function"><strong>pg_last_error()</strong></span> 返回指定连接 <code class="parameter">connection</code> 的最后一条错误信息。
    </p>
    <p class="para">
     错误信息可能会被 PostgreSQL(libpq) 的内部函数调用所覆盖。如果 PostgreSQL 的内部模块函数产生了多个错误，则可能不能返回适当的错误信息。
    </p>
    <p class="para">
     使用 <span class="function"><a href="function.pg-result-error.html" class="function">pg_result_error()</a></span>，<span class="function"><a href="function.pg-result-status.html" class="function">pg_result_status()</a></span> 和 <span class="function"><a href="function.pg-connection-status.html" class="function">pg_connection_status()</a></span> 来取得更好的错误处理。
    </p>
    <blockquote class="note"><p><strong class="note">注意</strong>: 
     <p class="para">
      本函数以前的名字为 <code class="literal">pg_errormessage()</code>。
     </p>
    </p></blockquote>
    <p class="para">
     参见 <span class="function"><a href="function.pg-result-error.html" class="function">pg_result_error()</a></span>。
    </p>
   </div>

  </div></div></div></body></html>